import greenfoot.*;  

public class control  extends Actor
{
    GreenfootImage screen = new GreenfootImage(600,400);
    int level=1,a=0;
    boolean leaving=false,coming=true,killed=false;
    
    public control(int l){
        level=l;
        setImage(screen); 
        screen.fillRect(0,0,600,400);
    }
    
    
    public void act() 
    {
        if(coming){
            screen.clear();
            screen.fillRect(a,0,600,400);
            a=a+15;
            if(a==630){
                coming=false;
                a=0;
                setImage(new GreenfootImage(1,1));
            }
        }
        
        if(leaving){  
            screen.fillRect(0,0,a,400);
            a=a+15;
            if(a==630)
                killAll();
            }  
            
        
    } 
    
    public void killAll(){
        if(killed)level--;
        ((it) getWorld()).done(level);
    }
    
    public void done(boolean k){
        killed=k;
        if(!leaving){
            screen = new GreenfootImage(600,400);
            setImage(screen);
        }
        leaving=true;
    }
    
    
    
    
    
}
